<?php
/*
 * 幻灯片小插件
 */
namespace Mobile\Widget;
use Think\Controller;
use Mobile\Model\focusModel;

class SlideWidget extends Controller {
    
    public $focusModel;
    
    public function __construct() {
        parent::__construct();
        $this->focusModel = new focusModel();
    }
    
    /*
     *幻灯片轮播
     */
    public function index(){
        layout(false);
        //获取幻灯片
        $where = array(
            "status" => 1,
            "position" => 1
        );
        $focus_list = $this->focusModel->getFocusLists($where);
        
        if(!empty($focus_list)){
            $this->assign('focus_list',$focus_list);
            $this->display("Slide/index");
        }
    }

    public function zixun(){
        layout(false);
        $list = M('order')->where(array(
            'checked' => array('in',array(1,2,5))
        ))
        ->order('order_id desc')
        ->page(1,10)
        ->field('order_title as title')->select();
        foreach($list as $k=>$v) {
            $list[$k]['title'] = "最新订单:".$v['title'];
        }
        
        $this->assign('zixunlist',$list);
        $this->display("Slide/zixun");  
    }
    
    /*
     * 商品幻灯片
     */
    public function goods($goods){
        layout(false);
        //获取幻灯片
        $focus_list = json_decode($goods['goods_thumb'],true);
        if(!empty($focus_list)){
            $this->assign('focus_list',$focus_list);
            $this->display("Slide/goods");
        }
    }

    public function article(){
        layout(false);
        //获取幻灯片
        $where = array(
            "status" => 1,
            "position" => 2
        );
        $focus_list = $this->focusModel->getFocusLists($where);
        if(!empty($focus_list)){
            $this->assign('focus_list',$focus_list);
            $this->display("Slide/article");
        }
    }

     
}